package com.xy.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.xy.request.DataRequest;
import com.xy.response.DataResponse;
import com.xy.service.DataThirdService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@AllArgsConstructor
@RequestMapping("data-third")
@Api(value = "第三方数据管理", tags = "第三方数据管理")
public class DataThirdController extends BladeController {

	private final DataThirdService dataThirdService;
	/**
	 * 用户数据推送
	 *
	 * @param dataRequest
	 * @return
	 */
	@PostMapping("/push-save")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "用户数据推送", notes = "dataRequest")
	public R<DataResponse> save(@Valid @RequestBody DataRequest dataRequest) {

		return data(dataThirdService.saveData(dataRequest));
	}
	/**
	 * 用户数据推送修改
	 *
	 * @param dataRequest
	 * @return
	 */
	@PostMapping("/push-update")
	@ApiOperationSupport(order = 4)
	@ApiOperation(value = "用户数据推送修改", notes = "传入 dataRequest")
	public R<DataResponse> update(@Valid @RequestBody DataRequest dataRequest) {

		return data(dataThirdService.updateData(dataRequest));
	}
}
